from urllib import request, parse

url = 'http://httpbin.org/post'

headers = {
    "Accept": "application/json",
    "Accept-Encoding": "gzip, deflate",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Content-Length": "0",
    "Dnt": "1",
    "Host": "www.httpbin.org",
    "Origin": "http://www.httpbin.org",
    "Referer": "http://www.httpbin.org/",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36",
    "X-Amzn-Trace-Id": "Root=1-61961727-0468590271f1d535389e58b1"
}

dict = {
    'name': 'value'
}

data = bytes(parse.urlencode(dict), encoding='utf8')
req = request.Request(url=url, data=data, headers=headers, method='POST')
response = request.urlopen(req)
print(response.read().decode('utf8'))
